﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Interop;

namespace iControl
{
    static class Win32
    {
        #region Variable Declaration
        public const Int32 GWL_EXSTYLE = -20;
        public const Int32 WS_EX_TOOLWINDOW = 0x80;
        public const Int32 WS_EX_APPWINDOW = 0x40000;
        #endregion

        #region PInvokes
        [DllImport("user32.dll")]
        private static extern Int32 SetWindowLong(IntPtr window, Int32 index, Int32 value);
        
        [DllImport("user32.dll")]
        private static extern Int32 GetWindowLong(IntPtr window, Int32 index);

        [DllImport("user32.dll", SetLastError = true)]
        public static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);
        #endregion

        #region Methods
        public static void HideWindowFromCtrlAltDelete(System.Windows.Window window)
        {
            IntPtr windowPtr = new WindowInteropHelper(window).Handle;

            SetWindowLong(windowPtr, GWL_EXSTYLE,
                (GetWindowLong(windowPtr, GWL_EXSTYLE) | WS_EX_TOOLWINDOW) & ~WS_EX_APPWINDOW);

        }

   
        #endregion
    }
}
